"use strict"
//查询在线信息
const mvc = require("cosjs.mvc");
exports.query = async function () {
    const sid = this.get('sid', 'int');
    let item = mvc.model.mongo('role', sid);
    let option = { "multi": true, "dataType": "array", "limit": 300000, 'batchSize': 3000 };
    let query = {};
    let ret = await item.find(query, option);
    let result = {}
    let coll = [];

    for (let i = 0; i < ret.length; ++i) {
        let role = ret[i];
        if (!result[role.lv]) {
            result[role.lv] = {};
            result[role.lv].lv = role.lv;
            result[role.lv].num = 0;
            coll.push(result[role.lv]);
        }
        result[role.lv].num++;
    }
    return coll;
}